package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysDeptExtension;
import com.ruoyi.system.service.ISysDeptExtensionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 组织扩展信息Controller
 * 
 * @author ruoyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/system/org_extension")
public class SysDeptExtensionController extends BaseController
{
    @Autowired
    private ISysDeptExtensionService sysDeptExtensionService;

    /**
     * 查询组织扩展信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:org_extension:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysDeptExtension sysDeptExtension)
    {
        startPage();
        List<SysDeptExtension> list = sysDeptExtensionService.selectSysDeptExtensionList(sysDeptExtension);
        return getDataTable(list);
    }

    /**
     * 导出组织扩展信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:org_extension:export')")
    @Log(title = "组织扩展信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysDeptExtension sysDeptExtension)
    {
        List<SysDeptExtension> list = sysDeptExtensionService.selectSysDeptExtensionList(sysDeptExtension);
        ExcelUtil<SysDeptExtension> util = new ExcelUtil<SysDeptExtension>(SysDeptExtension.class);
        util.exportExcel(response, list, "组织扩展信息数据");
    }

    /**
     * 获取组织扩展信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:org_extension:query')")
    @GetMapping(value = "/{deptExtId}")
    public AjaxResult getInfo(@PathVariable("deptExtId") Long deptExtId)
    {
        return success(sysDeptExtensionService.selectSysDeptExtensionByDeptExtId(deptExtId));
    }

    /**
     * 新增组织扩展信息
     */
    @PreAuthorize("@ss.hasPermi('system:org_extension:add')")
    @Log(title = "组织扩展信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDeptExtension sysDeptExtension)
    {
        return toAjax(sysDeptExtensionService.insertSysDeptExtension(sysDeptExtension));
    }

    /**
     * 修改组织扩展信息
     */
    @PreAuthorize("@ss.hasPermi('system:org_extension:edit')")
    @Log(title = "组织扩展信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDeptExtension sysDeptExtension)
    {
        return toAjax(sysDeptExtensionService.updateSysDeptExtension(sysDeptExtension));
    }

    /**
     * 删除组织扩展信息
     */
    @PreAuthorize("@ss.hasPermi('system:org_extension:remove')")
    @Log(title = "组织扩展信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deptExtIds}")
    public AjaxResult remove(@PathVariable Long[] deptExtIds)
    {
        return toAjax(sysDeptExtensionService.deleteSysDeptExtensionByDeptExtIds(deptExtIds));
    }
}
